package com.sxpi.controller;

import com.sxpi.common.result.Result;
import com.sxpi.service.LikesService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/likes")
public class LikesController {
    @Resource
    private LikesService likesService;

    /**
     * 处理点赞或取消点赞请求
     * @param userId 用户ID
     * @param isLike 是否点赞（1表示点赞，0表示取消点赞）
     * @param likeData 包含 workId 和 costumesId 的请求体
     * @return 操作结果和点赞数量
     */
    @PostMapping("/picture")
    public Result<Map<String, Object>> handleLike(@RequestParam("userId") Long userId,
                                                @RequestParam("isLike") Integer isLike,
                                                @RequestBody Map<String, String> likeData) {
        return likesService.handleLike(userId, isLike, likeData);
    }
}
